package com.dongdongsongcan.app.db;

import java.util.List;

import com.dongdongsongcan.app.db.bean.User;
import com.lidroid.xutils.db.sqlite.WhereBuilder;
import com.lidroid.xutils.exception.DbException;
import com.su.dolphin.model.db.DpBaseDao;
import com.su.dolphin.utils.LogUtil;

public class UserDao extends DpBaseDao {

    public static boolean deleteUser(User user) {
        try {
            getDb().delete(User.class, WhereBuilder.b().expr("id", "=", user.getId()));
            //getUsers();
            return true;
        } catch (DbException e) {
            e.printStackTrace();
        }
        return false;
    }


    public static boolean saveUser(User user) {
        try {
            getDb().save(user);
            //getUsers();
            return true;
        } catch (DbException e) {
            e.printStackTrace();
        }
        return false;
    }


    public static User getUser() {
        try {
            User user = getDb().findFirst(User.class);
            return user;
        } catch (DbException e) {
            e.printStackTrace();
        }
        return null;
    }

}
